package com.study.java.classloader.myClassLoader.DecryptClassLoader;

import org.junit.Test;

/**
* @Name: EncryptTest
* @Description: 加密操作测试类
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-2-9 下午4:46:25 
* @Version: V1.0
 */
public class ClassLoaderTest {
	
	/**
	* @Name: encryptTest
	* @Description: 简单加密：字节按位取反操作测试
	* @Author: 李超	lc_jack@foxmail.com
	* @Version: V1.0
	* @CreateDate: 2017-2-9 下午4:50:25
	* @Parameters: 
	* @Return: void
	 */
	@Test
	public void encryptTest() {
		int a = 3 ;
		System.out.println(Integer.toBinaryString(a));
		System.out.println(Integer.toBinaryString(a^0xff));
	}

	/**
	* @Name: encryptByteCodeFileTest
	* @Description: 将指定的字节码文件进行加密操作
	* @Author: 李超	lc_jack@foxmail.com
	* @Version: V1.0
	* @CreateDate: 2017-2-9 下午4:49:50
	* @Parameters: 
	* @Return: void
	 */
	@Test
	public void encryptByteCodeFileTest() {
		String src = "D:\\myjava\\HelloWorld.class" ;
		String dest = "D:\\myjava\\temp\\HelloWorld.class" ;
		EncryptUtil.encry(src, dest) ;
	}
	
	/**
	* @Name: decryClassLoaderTest
	* @Description: 解密类加载器解密并加载字节码文件测试
	* @Author: 李超	lc_jack@foxmail.com
	* @Version: V1.0
	* @CreateDate: 2017-2-9 下午5:05:28
	* @Parameters: 
	* @Return: void
	 */
	@Test
	public void decryClassLoaderTest() {
		String rootDir = "d:/myjava/temp" ;
		DecryptClassLoader d1 = new DecryptClassLoader(rootDir) ;
		try {
			Class<?> h1 = d1.loadClass("HelloWorld") ;
			System.out.println(h1);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	
}
